CMAKE_MINIMUM_REQUIRED(VERSION 3.22.2)
project(division_shader_compiler LANGUAGES CXX)

include(GenerateExportHeader)

set(CMAKE_CXX_STANDARD 17)

if(DIVISION_SHADER_COMPILER_EXECUTABLE)
        option(ENABLE_GLSLANG_INSTALL "Disable glslang installation" OFF)
else()
        option(ENABLE_GLSLANG_INSTALL "Enable glslang installation" ON)
endif()

option(ENABLE_GLSLANG_BINARIES "Disable glslang binaries" OFF)
option(ENABLE_SPVREMAPPER "Enables building of SPVRemapper" OFF)
option(SPIRV_CROSS_CLI "Disable SPIRV CLI." OFF)

add_subdirectory(third_party/glslang-12.1.0)
add_subdirectory(third_party/SPIRV-Cross-sdk-1.3.243.0)

add_library(division_shader_compiler src/interface.cpp)

target_include_directories(
        division_shader_compiler 
        PUBLIC 
        ${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR})
target_link_libraries(
        division_shader_compiler
        glslang SPIRV glslang-default-resource-limits spirv-cross-cpp spirv-cross-msl)

target_link_directories(division_shader_compiler PUBLIC ${PROJECT_BINARY_DIR})
GENERATE_EXPORT_HEADER(division_shader_compiler EXPORT_MACRO_NAME DIVISION_EXPORT)

if(DIVISION_SHADER_COMPILER_EXECUTABLE)
        add_executable(division_shader_compiler_exec src/main.cpp)
        target_link_libraries(division_shader_compiler_exec division_shader_compiler)
else()
        install(TARGETS division_shader_compiler DESTINATION ${CMAKE_INSTALL_NAME_DIR})
endif()